<?php
include_once('DataBase.php');
/*
 * Class designed to model the databases table 'LibUser'
 */
class LibUser{
    //Attributes
    
    //Users login name
    private $login;
    //Users password
    private $pssw;
    //Users name
    private $name;
    //Users last name
    private $lastName;
    
    //Methods
    /*
     * Builds an object with the specified attributes set
     *
     * Parameters: $login -> Login name of the user
     *             $pssw -> Password for the user
     *             $name -> Users name
     *             $lastName -> Users last name
     * Return value: Object containing a LibUser with the specified attributes
     */
    public function __construct($login, $pssw, $name, $lastName){
        $this->login = $login;
        $this->pssw = $pssw;
        $this->name = $name;
        $this->lastName = $lastName;        
    }
    
    /*
     * Find in the database a specified user using its login
     *
     * Parameters: $login -> Unique identifier for the user
     * Return value: A LibUser object containing the information of the desired
     *               user or null if it was not found.
     */
     public static function findLibUser($login){
        $database = DataBase::getInstance();
        return $database->selectLibUser($login);        
     }
     
    //List of getters
    public function getLogin(){return $this->login;}
    public function getPssw(){return $this->pssw;}
    public function getName(){return $this->name;}
    public function getLastName(){return $this->lastName;}
    
    //List of setters
    public function setLogin($a){$this->login = $a;}
    public function setPssw($a){$this->pssw = $a;}
    public function setName($a){$this->name = $a;}
    public function setLastName($a){$this->lastName = $a;}
}
?>